import 'package:flutter/material.dart';
import 'package:uikit/uikit.dart';
import 'package:uikit/utils/screen_util/size_extension.dart';

///登录动效，自定义widget
class LoginEffect extends StatefulWidget {
  final bool protect;

  const LoginEffect({Key? key, required this.protect}) : super(key: key);

  @override
  _LoginEffectState createState() => _LoginEffectState();
}

class _LoginEffectState extends State<LoginEffect> {
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: 10.w),
      decoration: BoxDecoration(
        color: Colors.grey[100],
        border: Border(bottom: BorderSide(width: 0.5.w, color: Colors.grey)),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          _buildImageWidget(true),
          _buildTitleImageWidget(),
          _buildImageWidget(false),
        ],
      ),
    );
  }

  Widget _buildImageWidget(bool left) {
    var headLeft = widget.protect ? 'assets/images/head_left_protect.png' : 'assets/images/head_left.png';
    var headRight = widget.protect ? 'assets/images/head_right_protect.png' : 'assets/images/head_right.png';
    return ImageUtil.loadAssetImage(
      left ? headLeft : headRight,
      height: 90.w,
      //package: RikiUikit.PACKAGE,
    );
  }

  Widget _buildTitleImageWidget() {
    return ImageUtil.loadAssetImage(
      'assets/images/logo.png',
      width: 90.w,
      height: 90.w,
      //package: RikiUikit.PACKAGE,
    );
  }
}
